--- // 月別・年度別アーカイブ(/kodaira/events/2026-09/、/kodaira/events/r7/ など)。 // 前々月以前の予定だけを静的ページにする(前月以降はメインページに載せる)。 import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; import ScheduleTable from '@/components/ScheduleTable.astro'; import { archiveFiscalYearKeys, archiveMonthKeys, fiscalYearLabel, fiscalYearOf, monthCounts, monthLabel, monthsInFiscalYear, rowsInFiscalYear, rowsInMonth, } from '@/lib/schedule-months'; import { SCHEDULE_BASE_PATH } from '@/data/schedule/config'; export function getStaticPaths() { return [ ...archiveMonthKeys.map((key, i) => ({ params: { period: key }, props: { kind: 'month' as const, key, prev: archiveMonthKeys[i - 1] ?? null, next: archiveMonthKeys[i + 1] ?? null, }, })), ...archiveFiscalYearKeys.map((key, i) => ({ params: { period: key }, props: { kind: 'fiscal' as const, key, prev: archiveFiscalYearKeys[i - 1] ?? null, next: archiveFiscalYearKeys[i + 1] ?? null, }, })), ]; } const { kind, key, prev, next } = Astro.props as { kind: 'month' | 'fiscal'; key: string; prev: string | null; next: string | null; }; const label = kind === 'fiscal' ? fiscalYearLabel(key) : monthLabel(key); const periodLabel = (period: string) => kind === 'fiscal' ? fiscalYearLabel(period) : monthLabel(period); const meetingRows = kind === 'fiscal' ? rowsInFiscalYear(key, 'meeting') : rowsInMonth(key, 'meeting'); const eventRows = kind === 'fiscal' ? rowsInFiscalYear(key, 'event') : rowsInMonth(key, 'event'); // 年度ページでは、その年度の月別ページへの一覧も並べる。 const months = kind === 'fiscal' ? monthsInFiscalYear(key) : []; // 月別ページから年度ページに戻れるのは、その年度のページが存在するときだけ。 const fiscalYearForKey = kind === 'month' ? fiscalYearOf(key) : null; const hasFiscalPage = fiscalYearForKey !== null && archiveFiscalYearKeys.includes(fiscalYearForKey); const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`; // 期間がすべて過去か、すべて未来か、今日を含むかで説明文を変える。 // (過去の月に「今後の予定です」と書いたり、未来の月に「終了分も掲載」と書いたりしない) const pad = (n: number) => String(n).padStart(2, '0'); const now = new Date(); const currentMonth = `${now.getFullYear()}-${pad(now.getMonth() + 1)}`; const periodMonths = kind === 'fiscal' ? monthsInFiscalYear(key) : [key]; const firstMonth = periodMonths[0] ?? key; const lastMonth = periodMonths[periodMonths.length - 1] ?? key; const isAllPast = lastMonth < currentMonth; const isAllFuture = firstMonth > currentMonth; const lead = isAllPast ? `${label}の小平市のイベントと、審議会等・市議会の予定を、記録として掲載しています。` : isAllFuture ? `${label}の小平市のイベントと、審議会等・市議会の開催予定です。` : `${label}の小平市のイベントと、審議会等・市議会の開催予定です。開催日が過ぎたものもあわせて掲載しています。`; const caution = isAllPast ? '掲載内容は、掲載時点のものです。' : '変更になることがありますので、各問い合わせ先へご確認ください。'; const description = isAllPast ? `${label}に開催された小平市のイベントと、審議会・市議会の予定の記録です。日程・会場を確認できます。` : `${label}の小平市のイベントと、審議会・市議会の開催予定の一覧です。日程・会場・申込期限を確認できます。`; ---

← 小平市のイベント・行事予定カレンダー(今後)に戻る

{lead}{caution}

{ kind === 'fiscal' && ( ) } { meetingRows.length > 0 && ( <>

審議会等・市議会の開催予定

) } { eventRows.length > 0 && ( <>

イベント

) } { kind === 'month' && hasFiscalPage && fiscalYearForKey && ( ) }